home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / mkmf.bigcmd < prev    next >
Encoding:
Text File  |  1992-06-10  |  3.1 KB  |  97 lines

  1. #!/sprite/cmds/csh -f
  2. #
  3. # A script to generate (or regenerate) a Makefile for one subdirectory
  4. # of a command whose sources are spread across many subdirectories.
  5. #
  6. # This script is invoked from mkmf.  See the mkmf manual page for
  7. # details on how mkmf works.
  8. #
  9. # Parameters passed in from mkmf as environment variables:
  10. #    DOMACHINES    names of machines we are supposed to run mkmf on
  11. #    MKMFDIR        directory containing prototype makefiles
  12. #    MKMFFLAGS    arguments to all mkmfs run recursively
  13. #    MACHINES    list of machine names (e.g. "sun2 sun3"), for
  14. #            which there are machine-specific subdirectories
  15. #            (sun2.md, sun3.md) to hold the object files and
  16. #            any machine-specific source files to use when
  17. #            compiling for that machine
  18. #    MAKEFILE    name of makefile to create
  19. #    SUBTYPE        information about the type makefile
  20. #
  21. # Several of these environment variables must be copied to local shell
  22. # variables before use, because shell variables can be used in some places
  23. # where environment variables can't.
  24. #            
  25. # $Header: /sprite/lib/mkmf/RCS/mkmf.bigcmd,v 1.9 92/06/10 13:04:45 jhh Exp $ (SPRITE) Berkeley
  26. #
  27.  
  28. #
  29. # Argument processing.  (Generalized form, even though just one flag so far.)
  30. #
  31. while ($#argv >= 1)
  32.     if ("$1" == '-x') then
  33.     set echo
  34.     endif
  35.     shift
  36. end
  37.  
  38. set subtype=$SUBTYPE
  39. set module=$cwd:t
  40. set pref='[a-z_A-Z]'
  41. set machines=($MACHINES)
  42. set domachines = ($DOMACHINES)
  43. set makefile=$MAKEFILE
  44. set distdir=($DISTDIR)
  45. if (-e $makefile.proto) then
  46.     set proto=$makefile.proto
  47. else
  48.     set proto="${MKMFDIR}/Makefile.bigcmd"
  49. endif
  50.  
  51. echo "Generating $makefile for module $module from $proto"
  52.  
  53. set nonomatch
  54. set allSrcs =( ${pref}*.[cylsp] )
  55. #
  56. # Check to see if there were any sources.  The first check (size == 1)
  57. # is only necessary because the second check will cause an error if
  58. # allSrcs contains more than 1024 bytes.
  59. #
  60. if ($#allSrcs == 1) then
  61.     if ("$allSrcs" == "${pref}*.[cylsp]") set allSrcs=()
  62. endif
  63. set mdsrcs =( *.md/${pref}*.[cylsp] )
  64. if ($#mdsrcs == 1) then
  65.     if ("$mdsrcs" == "*.md/${pref}*.[cylsp]") set mdsrcs=()
  66. endif
  67. set allSrcs=($allSrcs $mdsrcs)
  68. unset nonomatch
  69.  
  70. #
  71. # Use sed to substitute various interesting things into the prototype
  72. # makefile. The code below is a bit tricky because some of the variables
  73. # being substituted in can be very long:  if the substitution is passed
  74. # to sed with "-e", the entire variable must fit in a single shell argument,
  75. # with a limit of 1024 characters.  By generating a separate script file
  76. # for the very long variables, the variables get passed through (to the
  77. # script file) as many arguments, which gets around the length problem.
  78. #
  79.  
  80. rm -f mkmf.tmp.sed
  81. echo s,"@(ALLSRCS)",$allSrcs,g > mkmf.tmp.sed
  82. cat $proto | sed -f mkmf.tmp.sed \
  83.     -e "s,@(DATE),`date`,g" \
  84.     -e "s,@(MACHINES),$machines,g" \
  85.     -e "s,@(MAKEFILE),$makefile,g" \
  86.     -e "s,@(NAME),$module,g" \
  87.     -e "s,@(TEMPLATE),$proto,g" \
  88.     -e "s,@(DISTDIR),$distdir,g" \
  89.     -e "s,@(TYPE),$subtype,g" \
  90.     > $makefile
  91. rm -f mkmf.tmp.sed
  92.  
  93. setenv PARENTDIR $cwd
  94. foreach i ($domachines)
  95.     (cd $i.md; mkmf $MKMFFLAGS -f md.mk; mv md.mk md.mk.tmp; sed -e "s| $i\.md/linked\.o||g" md.mk.tmp > md.mk; rm -f md.mk.tmp)
  96. end
  97.